---
id: 655774d01daeeaa1978b99d5
title: ステップ 24
challengeType: 20
dashedName: step-24
---

# --description--

At the beginning, all the other nodes in the graph are considered to be at infinite distance from the source node, because the distance has not been determined yet.

Create an `else` clause and assign an infinite value to the node in the `distances` dictionary. For that, use the `float()` function with the string `inf` as argument to generate a floating point number representing the positive infinity.

# --hints--

You should have an `else` clause.

```js
({ test: () =>  {
    const shortest = __helpers.python.getDef(code, "shortest_path");
    const {function_body} = shortest;    
    assert(function_body.match(/^(\s*)if.*:.*^\1else\s*:/ms));
  }
})
```

You should assign `float('inf')` to `distances[node]` inside your new `else` clause.

```js
({ test: () =>  {
    const shortest = __helpers.python.getDef(code, "shortest_path");
    const {function_body} = shortest;    
    assert(function_body.match(/^(\s*)if.*:.*^\1else\s*:\s*^\1\s{4}distances\s*\[\s*node\s*\]\s*=\s*float\s*\(\s*("|')inf\2\s*\)/ms));
  }
})
```

# --seed--

## --seed-contents--

```py
my_graph = {
    'A': [('B', 3), ('D', 1)],
    'B': [('A', 3), ('C', 4)],
    'C': [('B', 4), ('D', 7)],
    'D': [('A', 1), ('C', 7)]
}

--fcc-editable-region--
def shortest_path(graph, start):
    unvisited = []
    distances = {}
    for node in graph:
        unvisited.append(node)
        if node == start:
            distances[node] = 0
--fcc-editable-region--
```
